#define _CRT_SECURE_NO_WARNINGS  1


class Solution
{
public:
    int maxArea(vector<int>& height)
    {
        int left = 0;
        int right = height.size() - 1;
        int sum = 0;
        while (left < right)
        {
            if (height[right] > height[left])
            {
                if (height[left] * (right - left) > sum)
                    sum = height[left] * (right - left);
                left++;
            }
            else
            {
                if (height[right] * (right - left) > sum)
                    sum = height[right] * (right - left);
                right--;
            }
        }
        return sum;
    }
};